# -*- coding:utf-8 -*-
# @FileName  :t16.py
# @Time      :2021/7/15 16:03
import base64
import io
import json
import sys
import time
from urllib.parse import quote
from fontTools.ttLib import TTFont
import execjs
import requests
import xmltodict

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='gb18030')
list2 = {
    '1,0,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,1,0,1,0,0,0,': 2,
    '1,1,1,1,1,1,1,': 7,
    '1,0,0,1,1,0,1,1,1,1,': 1,
    '1,0,0,1,0,1,0,1,0,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,': 9,
    '1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,': 4,
    '1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,1,1,1,1,': 5,
    '1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,': 8,
    '1,0,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,0,0,': 6,
    '1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,0,0,1,0,': 0,
    '1,0,1,0,1,1,0,0,1,0,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,': 3,
}


def main(m, cc):
    global num,count
    datt = {}
    s = str(int(time.time()) * 1000)
    kv = {'User-Agent': 'yuanrenxue.project', 'cookie': 'sessionid=hbjmfoa4kyzbz05koioqtpds03qt9w7z;'}
    r = requests.get(f'http://match.yuanrenxue.com/api/match/7?page={m}', headers=kv).json()
    with open('7.woff', 'wb') as f:
        f.write(base64.b64decode(r['woff']))
    font = TTFont('7.woff')
    font.saveXML('7.xml')
    with open('7.xml', 'r') as f:
        xmldict = xmltodict.parse(f.read())
    for i in xmldict['ttFont']['glyf']['TTGlyph'][1:]:
        ww = json.loads(json.dumps(i))
        if len(ww['contour']) > 1:
            a = ''
            for j in ww['contour']:
                for s in j['pt']:
                    a += s['@on'] + ','
            datt[ww['@name']] = list2[a]
        else:
            b = ''
            for s in ww['contour']['pt']:
                b += s['@on'] + ','
            datt[ww['@name']] = list2[b]
    # print(datt)
    for i in r['data']:
        k = ''
        for j in i['value'].strip().split():
            j = j.replace("&#x", "uni")
            k += str(datt[j])
        print(k,name[count])
        count += 1

if __name__ == "__main__":
    num = []
    name = ['极镀ギ紬荕', '爷灬霸气傀儡', '梦战苍穹', '傲世哥', 'мaη肆風聲', '一刀メ隔世', '横刀メ绝杀', 'Q不死你R死你', '魔帝殤邪', '封刀不再战', '倾城孤狼', '戎马江湖', '狂得像风', '影之哀伤', '謸氕づ独尊', '傲视狂杀', '追风之梦',
            '枭雄在世', '傲视之巅', '黑夜刺客', '占你心为王', '爷来取你狗命', '御风踏血', '凫矢暮城', '孤影メ残刀', '野区霸王', '噬血啸月', '风逝无迹', '帅的睡不着', '血色杀戮者', '冷视天下', '帅出新高度', '風狆瑬蒗', '灵魂禁锢',
            'ヤ地狱篮枫ゞ', '溅血メ破天', '剑尊メ杀戮', '塞外う飛龍', '哥‘K纯帅', '逆風祈雨', '恣意踏江山', '望断、天涯路', '地獄惡灵', '疯狂メ孽杀', '寂月灭影', '骚年霸称帝王', '狂杀メ无赦', '死灵的哀伤', '撩妹界扛把子', '霸刀☆藐视天下',
            '潇洒又能打', '狂卩龙灬巅丷峰', '羁旅天涯.', '南宫沐风', '风恋绝尘', '剑下孤魂', '一蓑烟雨', '领域★倾战', '威龙丶断魂神狙', '辉煌战绩', '屎来运赚', '伱、Bu够档次', '九音引魂箫', '骨子里的傲气', '霸海断长空', '没枪也很狂',
            '死魂★之灵']
    count = 1
    for i in range(1, 6):
        main(i, name[count])
    # print(num)
